// Learn TypeScript:
//  - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
// Learn Attribute:
//  - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html

import AbstractView, { Binding, ViewModel } from "../../../../resources/framework/base/mvvm/AbstractView";
import common_view_model from "../../../../resources/mainModules/common/scripts/common_view_model";
import lobby_view_model from "../../../scripts/lobby_view_model";
import Power from "../prefab/power/power";

const {ccclass, property} = cc._decorator;

@ccclass
@ViewModel('lobby', lobby_view_model, true)
export default class lobby_main extends AbstractView<lobby_view_model> {

    @property(cc.Node)
    power: cc.Node = null;
    // LIFE-CYCLE CALLBACKS:

    onLoad () {
        
        // this.testShader.on(cc.Node.EventType.TOUCH_START,this.touchStart, this);
        // this.testShader.on(cc.Node.EventType.TOUCH_MOVE,this.touchMove, this);
    }


    start () {

    }

    @Binding __common_powersData(p_number: number) {
        this.power.getComponent(Power).power = p_number;
    }

    // setMatPro(x: number,y: number) {
    //     const spr = this.testShader.getComponent(cc.Sprite);
    //     const mat = spr.getMaterial(0);
    //     mat.setProperty('localCor',[x,y]);
        
    //     // mat.setProperty('localCors',);
    // }

    // touchMes(e: cc.Touch) {
    //     let fs = cc.view.getFrameSize();
    //     let ed = e.getLocation();
    //     let l: cc.Vec2 = this.testShader.convertToNodeSpaceAR(ed);
    //     let lw = this.testShader.convertToWorldSpaceAR(l);
    //     let ld: cc.Vec2 = e.getLocationInView();
    //     let noco = this.testShader.getContentSize();
    //     let lc = cc.v2(Math.floor(ed.x), Math.floor(ed.y));
    //     console.log('--getFrameSize fs--', fs);
    //     console.log('--e.getLocation ed--', ed);
    //     console.log('convertToNodeSpaceAR l', l);
    //     console.log('convertToWorldSpaceAR lc', lc);
    //     console.log('getLocationInView ld', ld);
    //     console.log('ed.x, cc.winSize.height-ed.y lw', lw);
    //     this.setMatPro(lc.x,lc.y);
    // }

    // touchStart(e: cc.Touch) {
    //     this.touchMes(e);
    // }

    // touchMove(e: cc.Touch){
    //     this.touchMes(e);
    // }

    // update (dt) {}
}
